/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright (c) 2013-2014 jfinal app. jfapp Group.
 */


define(['adminapp'], function ($app) {
    $app.navactive('recemsg_stat');

    var action_tpl = Handlebars.compile($(g.actiontpl).html());

    var msgtype = {
        "text" : "文本消息",
        "image" : "图片消息",
        "location" : "地理位置消息",
        "link" : "链接消息",
        "event" : "事件消息",
        "video" : "视频消息",
        "voice" : "语音消息"
    };

    $app.listtable({
        'sAjaxSource' : g.ctx + "admin/stat/recemsg/list",
        'aoColumns'   : [
            $app.checkall,
            $app.autono,
            {'mDataProp': 'wx_account' },
            {'mDataProp': 'recevie_time' }
        ],
        'aoColumnDefs': [
            {
                'aTargets': [3],
                'mData'   : null,
                'mRender' : function (data, type, full) {
                    var n = msgtype[full["message_type"]];
                    if (n) {
                        return n;
                    }
                    return "无法匹配消息类型";
                }
            },
            {
                'aTargets': [4],
                'mData'   : "recevie_time",
                'mRender' : function (data, type, full) {
                    return full["recevie_time"];
                }
            },
            {
                'aTargets': [5],
                'mData'   : null,
                'mRender' : function (data, type, full) {
                    return action_tpl(full);
                }
            }
        ]
    }, 'data-list');
});

